﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel;

namespace RuoVea.OmiApi.Auth.Test6.Controllers
{
    [ApiController]
    [Route("[controller]")]
    [ApiExplorerSettings(GroupName = "v0")]
    public class AuthController : ControllerBase
    {
        /// <summary>
        /// swagger登录检查
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost("/api/swagger/checkUrl"),NonAction]
        [DisplayName("swagger登录检查")]
        public int SwaggerCheckUrl()
        {
            return /*_cache.Get<bool>(CacheConst.SwaggerLogin) ? 200 :*/ 401;
        }

        ///// <summary>
        ///// swagger登录提交
        ///// </summary>
        ///// <param name="auth"></param>
        ///// <returns></returns>
        //[AllowAnonymous]
        //[HttpPost("/api/swagger/submitUrl"), NonAction]
        //[DisplayName("swagger登录提交")]
        //public int SwaggerSubmitUrl([FromForm] SpecificationAuth auth)
        //{
        //    var userName = App.GetConfig<string>("SpecificationDocumentSettings:LoginInfo:UserName");
        //    var password = App.GetConfig<string>("SpecificationDocumentSettings:LoginInfo:Password");
        //    if (auth.UserName == userName && auth.Password == password)
        //    {
        //        _cache.Set<bool>(CacheConst.SwaggerLogin, true);
        //        return 200;
        //    }
        //    return 401;
        //}
    }
}
